package mongo

import (
	"ezgin-example/i18n"

	"github.com/loebfly/ezgin"
)

type templateMgo struct{}

func (receiver templateMgo) Insert(value interface{}) error {
	db, returnDB, err := ezgin.DBLite.Mongo()
	if err != nil {
		return i18n.DbConnectErr.Error()
	}
	defer returnDB(db)

	err = db.C("template").Insert(&value)
	if err != nil {
		return i18n.DbInsertErr.ErrorWithMsg(err.Error())
	}
	return nil
}
